import React from 'react';
import { Switch, useLocation } from 'react-router-dom';
import microApp from '@/utils/microApp';

export default (props: any): React.ReactNode => {
  const loc = useLocation();

  const pathname = microApp.get('urlMap')
    ? microApp.get('urlMap')[location.pathname] || loc.pathname
    : loc.pathname;
  console.log('Route Wrapper location', location.pathname);
  console.log('Route Wrapper useLocation', loc.pathname);
  console.log('Route Wrapper actual', pathname);

  return <Switch location={{ ...loc, pathname }}>{props.children}</Switch>;
};
